use std::sync::Arc;

use serde::{Deserialize, Serialize};

pub mod utlis;

#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub enum FromClient {
    Join { group_name: Arc<String> },
    Post{
        group_name: Arc<String>,
        message: Arc<String>,
    },
    Leave {
        group_name: Arc<String>,
    },
}


#[derive(Debug, PartialEq, Deserialize, Serialize)]
pub enum FromServer {
    Message {
        group_name: Arc<String>,
        message: Arc<String>,
    },
    Error(String),
}

pub fn add(left: usize, right: usize) -> usize {
    left + right
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn it_works() {
        let result = add(2, 2);
        assert_eq!(result, 4);
    }
}


#[cfg(test)]
fn test_from_client_json() {
    use std::sync::Arc;

    let from_client = FromClient::Join {
        group_name: Arc::new("rust".to_string()),
    };
}